package com.suxin.shiro.jwt.listener;

import org.apache.shiro.authc.AuthenticationException;
import org.apache.shiro.authc.AuthenticationInfo;
import org.apache.shiro.authc.AuthenticationListener;
import org.apache.shiro.authc.AuthenticationToken;
import org.apache.shiro.subject.PrincipalCollection;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/**
 * @author Tang
 * @classname UserAuthenticationListener
 * @description [ 认证失败会触发的通知接口 ]
 * @date 2021/3/28 11:28
 */
public class UserAuthenticationListener implements AuthenticationListener {

    private Logger logger = LoggerFactory.getLogger(UserAuthenticationListener.class);

    @Override
    public void onSuccess(AuthenticationToken token, AuthenticationInfo info) {
        System.out.println("认证成功的通知...");
    }

    @Override
    public void onFailure(AuthenticationToken token, AuthenticationException ae) {
        System.out.println("认证失败的通知...");
        logger.error("认证异常了!",ae);
    }

    @Override
    public void onLogout(PrincipalCollection principals) {
        System.out.println("用户退出通知....");
    }
}